const mongoose = require('mongoose')

// 构建集合结构
const schema = new mongoose.Schema({
    name: { //名称
        type: String,
        unique:true,
        required:true
    },
    parentId: { //父级id
        type: mongoose.SchemaTypes.ObjectId,
        ref: 'Category'
    },
    grade:{ //分类等级
        type: Number,
        default: 0
    },
},{
    // 创建时间和更新时间
    timestamps: true
})

module.exports = mongoose.model('Category', schema, 'category')